package com.wut.clock.controller;

import com.wut.clock.common.api.CommonResult;
import com.wut.clock.service.ILikeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author ZYH
 * @unit D9Lab
 * @description 点赞管理
 * @date 2022/6/10 19:11
 */
@RequiredArgsConstructor
@RequestMapping("/like")
@RestController
@Api(value="点赞管理器",tags = {"点赞管理器"})
public class LikeController {

    private final ILikeService likeService;

    @ApiOperation("点赞")
    @PostMapping("like")
    public CommonResult<String> like(@RequestParam Integer entityId,
                                     @RequestParam Integer entityType,
                                     @RequestParam Integer targetUserId){
        likeService.like(entityId,entityType,targetUserId);
        return CommonResult.success();
    }

    @ApiOperation("获取点赞状态")
    @GetMapping("getEntityLikeStatus")
    public CommonResult getEntityLikeStatus(@RequestParam Integer entityId,
                                            @RequestParam Integer entityType){
        return CommonResult.success(likeService.getEntityLikeStatus(entityId,entityType));
    }

    @ApiOperation("获取实体的点赞数")
    @GetMapping("getEntityLikeCount")
    public CommonResult getEntityLikeCount(@RequestParam Integer entityId,
                                           @RequestParam Integer entityType){
        return CommonResult.success(likeService.getEntityLikeCount(entityId,entityType));
    }

    @ApiOperation("获取用户的获赞数")
    @GetMapping("getUserLikeCount")
    public CommonResult getUserLikeCount(@RequestParam Integer userId){
        return CommonResult.success(likeService.getUserLikeCount(userId));
    }


}
